﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace GabageFactory.Models
{
    public class StackArdealiteReposity : Reposity
    {
        public stack_ardealite_ditch GetDailyArdealiteDitchInfo(int stackId, DateTime date)
        {
            var dailyArdealiteDitchInfo = from s in _dataContext.stack_ardealite_ditches
                             where stackId == s.stack_id && s.date == date.Date
                             select s;

            if (dailyArdealiteDitchInfo != null && dailyArdealiteDitchInfo.Count() > 0)
            {
                return dailyArdealiteDitchInfo.First();
            }
            else
            {
                return null;
            }
        }

        public stack_ardealite_ditch CreateArdealiteDitchInfo(stack_ardealite_ditch ardealiteDitchInfo)
        {
            _dataContext.stack_ardealite_ditches.InsertOnSubmit(ardealiteDitchInfo);
            SubmitChanges();
            return ardealiteDitchInfo;
        }

        public bool DeleteArdealiteDitchInfo(stack_ardealite_ditch ardealiteDitchInfo)
        {
            _dataContext.stack_ardealite_ditches.DeleteOnSubmit(ardealiteDitchInfo);
            return true;
        }
    }
}